$u.o.assign Function
Syntax
Arguments
- targetObjectobject
An object that the values from another object will be added or assigned.
- sourceObjectobject
The object that contains the values to assign into OBJECT.
- keepOriginalValuesboolean
(Optional) A true/false value. Defines whether or not to overwrite existing values with the values found in sourceObject. If true, values will not be overwritten. If false, the value in sourceObject will overwrite the values in targetObject.
Description
Assigns the values from a source object to a target object.
Discussion
Assign the values from a source object to a target object. The first parameter is the object you want to assign to. The second parameter is the object you want to assign from. The optional third parameter is a true/false as to whether you would like to keep values that already occur in the object that is being assigned to, or whether you would like to overwrite them.
Example
var obj = {firstName: 'Bob', lastName: 'Thomas'};
var obj2 = {lastName: 'Duran', age: 32};
$u.o.assign(obj,obj2);
/* "obj" now equals: {firstName: 'Bob', lastName: 'Duran', age: 32}*/
obj = {firstName: 'Bob', lastName: 'Thomas'};
obj2 = {lastName: 'Duran', age: 32};
$u.o.assign(obj,obj2,true);
/* "obj" now equals: {firstName: 'Bob', lastName: 'Thomas', age: 32}*/